package jukebox.common;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class AspectLogging {
	private Log log = LogFactory.getLog(getClass());
	
	@Around("execution(public * jukebox.model..*DAO.*(..))")
	public Object logService(ProceedingJoinPoint point) throws Throwable{
		String className = point.getTarget().getClass().getName();
		String methodName = point.getSignature().getName();
		Object retval = null;
		try {
			log.info(className+"."+methodName);
			retval = point.proceed();
		} catch (Throwable e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw e;
		}
		return retval;
	}
}
